import {
  createRouter,
  createWebHashHistory,
  type RouteRecordRaw,
  type RouteRecordSingleView
} from 'vue-router'
import { installRouterGuard } from './guard'
 
const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login.vue')
  },
  {
    path: '/',
    name: 'layout',
    redirect: '/home',
    component: () => import('@/layout/index.vue'),
    meta: {
      title: '主页'
    },
    children: []
  }
]

interface PermissionRoute extends RouteRecordSingleView {
  permission: string[]
}

export const permissionRoutes: PermissionRoute[] = [
  {
    path: '/dict-data/:id(\\d+)',
    name: 'dict-data',
    permission: ['system:dict:info'],
    component: () => import('@/views/power/dict/data.vue'),
    meta: {
      title: '字典数据',
      path: 'dict-data'
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: constantRoutes
})

installRouterGuard(router)

export default router
